#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1

NCPU=$(shell grep -c processor /proc/cpuinfo)

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
else
CROSS= --build $(DEB_BUILD_GNU_TYPE)
endif

override_dh_auto_configure:

ifeq "$(DEB_DUMMY)" ""
	cmake -DBUILD_CONFIG=xtrabackup_release -DCMAKE_INSTALL_PREFIX=/usr \
	  -DINSTALL_MYSQLTESTDIR=/usr/share/percona-xtrabackup-test -DINSTALL_MANDIR=/usr/share/man .
else
	# Dummy binaries that avoid compilation
	echo 'main() { return 300; }' | gcc -x c - -o xtrabackup
	echo 'main() { return 300; }' | gcc -x c - -o xtrabackup_55
	echo 'main() { return 300; }' | gcc -x c - -o xtrabackup_56
	echo 'main() { return 300; }' | gcc -x c - -o xbstream
	echo 'main() { return 300; }' | gcc -x c - -o xbcrypt
endif

	#docbook-to-man debian/xtrabackup.sgml > xtrabackup.1
override_dh_auto_build:
	make -j$(NCPU)

override_dh_strip:
	dh_strip --dbg-package=percona-xtrabackup-dbg-22

%:
	dh $@

